import {defineStore} from "pinia";
import { Session } from '/@/utils/storage';


/**
 * TagsView 路由列表
 * @methods setTagsViewRoutes 设置 TagsView 路由列表
 * @methods setCurrenFullscreen 设置开启/关闭全屏时的 boolean 状态
 * */
const useTagsViewRoutes = defineStore('tagsViewRoutes',{
    //定义状态
    state:() =>({
        tagsViewRoutes: [],
        isTagsViewCurrenFull: false,
        favoriteRoutes: [],
    }),
    //定义修改状态的方法
    actions: {
        async setTagsViewRoutes(data) {
            this.tagsViewRoutes = data;
        },
        setCurrenFullscreen(bool) {
            Session.set('isTagsViewCurrenFull', bool);
            this.isTagsViewCurrenFull = bool;
        },
        async setFavoriteRoutes(item) {
            this.favoriteRoutes.push(item);
        },
        async delFavoriteRoutes(item) {
            this.favoriteRoutes.splice(this.favoriteRoutes.indexOf(item), 1);
        },
    },
    persist: {
        enabled: true,
        strategies: [
            {
                key: 'tagsViewRoutes', //自定义 Key值
                storage: localStorage, // 选择存储方式
            },
        ],
    },

})
export default useTagsViewRoutes